#!/usr/bin/python
# coding=utf-8

import plotly.graph_objs as drive
import plotly.plotly


class DatePlot:
    def __init__(self):
        print "时间表格！"

    @staticmethod
    def MakePlotTwo(x, title, **dicts):
        data = []
        for key in dicts:
            a = drive.Scatter(
                x=x,
                y=dicts.get(key),
                name=key,
                # line=dict(color='#17BECF'),
                opacity=1
            )
            data.append(a)

        layout = dict(
            title=title,
        )
        fig = dict(data=data, layout=layout)
        plotly.offline.plot(fig, filename=title + ".html")

    @ staticmethod
    def MakePlot(x, y, title):
        a = drive.Scatter(
            x=x,
            y=y,
            name="SSSSS",
            line=dict(color='#17BECF'),
            opacity=1
        )

        b = drive.Scatter(
            x=["2016-02-20", "2016-02-08", "2016-02-23"],
            y=[28.04, 20, 33],
            name="AAAAA",
            line=dict(color='#7F7F7F'),
            opacity=0.8
        )

        data = [a]

        layout = dict(
            title=title,
            # xaxis=dict(
            #     range=['2018-07-01', '2018-07-20'])
        )
        fig = dict(data=data, layout=layout)
        plotly.offline.plot(fig, filename=title + ".html")
